package com.ynny.chapter14.controller;
import com.ynny.chapter14.bean.R;
import com.ynny.chapter14.bean.User;
import com.ynny.chapter14.mapper.UserMapper;
import com.ynny.chapter14.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")


public class UserController {
    @Autowired
    UserService userService;
    //定义验证方法，实现验证输入的用户名是否正确，如果正确则跳转登录页面，不正确则提示错误信息


    @Autowired
    UserMapper userMapper;
    @RequestMapping("/login")
    public R login(String number, String password, String identity) {
        List<User> userList = userService.selectUserByNumberAndPasswordAndIdentity(number, password, identity);
        if (userList.size() > 0) {

            return R.ok(userList);

        } else {
            return R.fail(500,"用户名或密码错误");
        }

    }













}
